home *** CD-ROM | disk | FTP | other *** search
/ Master Visual Basic 3 / Master Visual Basic 3 (SAMS Publishing) (1994).ISO / mvprog / original / ch05 / clipdata.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-05-04  |  5.4 KB  |  159 lines

  1. VERSION 2.00
  2. Begin Form frmClipData 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "The ClipData Program"
  5.    ClientHeight    =   4020
  6.    ClientLeft      =   1545
  7.    ClientTop       =   1815
  8.    ClientWidth     =   7365
  9.    Height          =   4710
  10.    Icon            =   CLIPDATA.FRX:0000
  11.    Left            =   1485
  12.    LinkTopic       =   "Form1"
  13.    ScaleHeight     =   4020
  14.    ScaleWidth      =   7365
  15.    Top             =   1185
  16.    Width           =   7485
  17.    Begin ListBox lstMyList 
  18.       Height          =   1005
  19.       Left            =   3720
  20.       TabIndex        =   3
  21.       Top             =   2760
  22.       Width           =   3375
  23.    End
  24.    Begin ComboBox cboMyCombo 
  25.       BackColor       =   &H00C0C0C0&
  26.       Height          =   300
  27.       Left            =   240
  28.       TabIndex        =   2
  29.       Top             =   2760
  30.       Width           =   3015
  31.    End
  32.    Begin TextBox txtMyTextBox 
  33.       Height          =   2415
  34.       Left            =   240
  35.       MultiLine       =   -1  'True
  36.       ScrollBars      =   3  'Both
  37.       TabIndex        =   1
  38.       Top             =   240
  39.       Width           =   3015
  40.    End
  41.    Begin PictureBox picMyPicture 
  42.       Height          =   2415
  43.       Left            =   3720
  44.       ScaleHeight     =   2385
  45.       ScaleWidth      =   3345
  46.       TabIndex        =   0
  47.       Top             =   240
  48.       Width           =   3375
  49.    End
  50.    Begin Menu mnuFile 
  51.       Caption         =   "&File"
  52.       Begin Menu mnuExit 
  53.          Caption         =   "E&xit"
  54.       End
  55.    End
  56.    Begin Menu mnuEdit 
  57.       Caption         =   "&Edit"
  58.       Begin Menu mnuCopy 
  59.          Caption         =   "&Copy"
  60.       End
  61.       Begin Menu mnuCut 
  62.          Caption         =   "C&ut"
  63.       End
  64.       Begin Menu mnuPaste 
  65.          Caption         =   "&Paste"
  66.       End
  67.    End
  68. Option Explicit
  69. Sub Form_Load ()
  70.     ' Fill items inside the list control
  71.     lstMyList.AddItem "This is item 1 in the list"
  72.     lstMyList.AddItem "This is item 2 in the list"
  73.     lstMyList.AddItem "This is item 3 in the list"
  74.     lstMyList.AddItem "This is item 4 in the list"
  75.     lstMyList.AddItem "This is item 5 in the list"
  76.     lstMyList.AddItem "This is item 6 in the list"
  77.     ' Fill items inside the combo box control
  78.     cboMyCombo.AddItem "This is item 1 in the combo box"
  79.     cboMyCombo.AddItem "This is item 2 in the combo box"
  80.     cboMyCombo.AddItem "This is item 3 in the combo box"
  81.     cboMyCombo.AddItem "This is item 4 in the combo box"
  82.     cboMyCombo.AddItem "This is item 5 in the combo box"
  83.     cboMyCombo.AddItem "This is item 6 in the combo box"
  84. End Sub
  85. Sub mnuCopy_Click ()
  86.     ' Clear the clipboard
  87.     Clipboard.Clear
  88.     ' Copy the contents of the currently active
  89.     ' control to the clipboard.
  90.     If TypeOf Screen.ActiveControl Is TextBox Then
  91.        Clipboard.SetText Screen.ActiveControl.SelText
  92.     ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
  93.         Clipboard.SetText Screen.ActiveControl.Text
  94.     ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
  95.         Clipboard.SetData Screen.ActiveControl.Picture
  96.     ElseIf TypeOf Screen.ActiveControl Is ListBox Then
  97.         Clipboard.SetText Screen.ActiveControl.Text
  98.     Else
  99.        ' Don't perform the Copy operation
  100.        ' because there isn't any control with
  101.        ' the focus.
  102.     End If
  103. End Sub
  104. Sub mnuCut_Click ()
  105.     ' Do the Copy operation
  106.     mnuCopy_Click
  107.     ' Copy the contents of the currently active
  108.     ' control to the clipboard.
  109.     If TypeOf Screen.ActiveControl Is TextBox Then
  110.        Screen.ActiveControl.SelText = ""
  111.     ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
  112.         Screen.ActiveControl.Text = ""
  113.     ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
  114.         Screen.ActiveControl.Picture = LoadPicture()
  115.     ElseIf TypeOf Screen.ActiveControl Is ListBox Then
  116.         If Screen.ActiveControl.ListIndex >= 0 Then
  117.            Screen.ActiveControl.RemoveItem Screen.ActiveControl.ListIndex
  118.         End If
  119.     Else
  120.        ' Don't perform the Cut operation
  121.        ' because there isn't any control with
  122.        ' the focus.
  123.     End If
  124. End Sub
  125. Sub mnuExit_Click ()
  126.     End
  127. End Sub
  128. Sub mnuPaste_Click ()
  129.     ' Paste the contents of the clipboard to the
  130.     ' currently active control.
  131.     If TypeOf Screen.ActiveControl Is TextBox Then
  132.        Screen.ActiveControl.SelText = Clipboard.GetText()
  133.     ElseIf TypeOf Screen.ActiveControl Is ComboBox Then
  134.        Screen.ActiveControl.Text = Clipboard.GetText()
  135.     ElseIf TypeOf Screen.ActiveControl Is PictureBox Then
  136.        Screen.ActiveControl.Picture = Clipboard.GetData()
  137.     ElseIf TypeOf Screen.ActiveControl Is ListBox Then
  138.        Screen.ActiveControl.AddItem Clipboard.GetText()
  139.     Else
  140.        ' Don't perform the Copy operation
  141.        ' because there isn't any control with
  142.        ' the focus.
  143.     End If
  144. End Sub
  145. Sub picMyPicture_GotFocus ()
  146.     ' When the picture control gets the focus
  147.     ' change its border (so that the reader will
  148.     ' be able to see that this control now
  149.     ' has the focus).
  150.     picMyPicture.BorderStyle = 1
  151. End Sub
  152. Sub picMyPicture_LostFocus ()
  153.     ' When the picture control looses the focus
  154.     ' change its border (so that the reader will
  155.     ' be able to see that this control now
  156.     ' lost the focus).
  157.     picMyPicture.BorderStyle = 0
  158. End Sub
  159.